(ns dev.play
  (:require [kdtree :as kd]))

(defn rand-point []
  [(rand-int 100) (rand-int 100)])

(defn make-rand-points []
  (vec (set (repeatedly 1000 rand-point))))

(defn make-tree [x-points]
  (kd/build-tree x-points))


(defn neareast-p [x-points]
  (let [tree (make-tree (rest x-points))
        h (first x-points)]
    (kd/nearest-neighbor tree h)
    (let [tree (kd/delete tree h)
          h (second x-points)]
      (kd/nearest-neighbor tree h))))
